package com.zero.controller;

import com.zero.entity.Condition;
import com.zero.entity.Invest;
import com.zero.entity.InvestType;
import com.zero.service.InvestService;
import com.zero.service.InvestTypeService;
import com.zero.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/invest")
public class InvestController {

    @Autowired
    private InvestService investService;

    @Autowired
    private InvestTypeService investTypeService;

    @PostMapping("/type")
    public Result typeList(@RequestBody InvestType investType, HttpServletRequest request){
        return investTypeService.select(investType, request);
    }

    @GetMapping("/type")
    public Result typeList(HttpServletRequest request){
        return investTypeService.select(request);
    }

    @PostMapping("/addType")
    public Result addType(@RequestBody InvestType investType, HttpServletRequest request){
        return investTypeService.add(investType, request);
    }

    @GetMapping("/deleteType")
    public Result deleteType(@RequestParam("ids") String ids){
        return investTypeService.delete(ids);
    }

    @PostMapping("/updateType")
    public Result updateType(@RequestBody InvestType investType){
        return investTypeService.update(investType);
    }


    @PostMapping("/list")
    public Result investList(@RequestBody Condition condition, HttpServletRequest request){
        return investService.select(condition, request);
    }

    @PostMapping("addInvest")
    public Result addInvest(@RequestBody Invest invest, HttpServletRequest request){
        return investService.add(invest, request);
    }

    @GetMapping("/deleteInvest")
    public Result deleteInvest(@RequestParam("ids") String ids){
        return investService.delete(ids);
    }

    @PostMapping("/updateInvest")
    public Result updateInvest(@RequestBody Invest invest, HttpServletRequest request){
        return investService.update(invest, request);
    }

    @PostMapping("/retrieveInvest")
    public Result retrieveInvest(@RequestBody Map map, HttpServletRequest request){
        return investService.retrieveInvest(map, request);
    }


}
